package com.sh.贪心算法;

import java.lang.management.ManagementFactory;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description:
 */
public class 跳跃游戏 {
    public static void main(String[] args) {

    }

    public boolean canJump(int[] nums) {

        int arm = nums.length;  // 长度
        int currentArm = 0;  // 目前可以到达的最远距离
        for (int i = 0; i < nums.length; i++) {
            if (i <= currentArm) {
                currentArm = Math.max(currentArm, i + nums[i]);
                if (currentArm >= (arm - 1)) return true;
            }
        }
        return false;
    }
}

